<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class Penanganan_model extends CI_Model {

    function __construct() {
        parent::__construct();
        $this->CI = get_instance();
    }

    function insert($data) {
        $this->db->insert('penanganan', $data);
    }


    //list flexy
    function get_data($id_keping) {
        //Build contents query
		$this->db->select('*');
		$this->db->from('penanganan');
		//$this->db->join('santri as s', 'ks.id_santri = s.id_santri', 'left');
		$this->db->where('ID_KEPING', $id_keping);
		$this->CI->flexigrid->build_query();
		
		

        //Get contents
        $return['records'] = $this->db->get();

        //Build count query
		$this->db->select('*');
		$this->db->from('penanganan');
		//$this->db->join('santri as s', 'ks.id_santri = s.id_santri', 'left');
		$this->db->where('ID_KEPING', $id_keping);
		$this->CI->flexigrid->build_query(FALSE);

        $return['record_count'] = $this->db->count_all_results();

        //Return all
        return $return;
    }

    function delete($id) {
        $this->db->where('ID_PENANGANAN', $id);
        $this->db->delete('penanganan');
    }

	
	function selectone($id) {
        $this->db->select("*");
        $this->db->from('penanganan');
        $this->db->where('ID_PENANGANAN', $id);
        $query = $this->db->get();
        return $query;
    }

    function update($id, $data) {
        $this->db->where('ID_PENANGANAN', $id);
        $this->db->update('penanganan', $data);
    }

	
}

?>